home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15941 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.logicon.com!newsmaster@klee
  2. From: kkolda@logicon.com (Kenneth D. Kolda)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: creating an ostrstream object screws up the istream object!
  5. Date: 8 Apr 1996 21:02:08 GMT
  6. Organization: Logicon Operating Systems
  7. Message-ID: <4kbusg$6jh@piper.logicon.com>
  8. References: <DpI5IK.DBG@cdf.toronto.edu>
  9. NNTP-Posting-Host: 137.51.122.161
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.99.2
  12.  
  13. In article <DpI5IK.DBG@cdf.toronto.edu>, a209dowm@cdf.utoronto.ca says...
  14. >
  15. >in this function I can read & write to the in_stream with no problem
  16. >
  17. >int object_name::func_name (ifstream &in_stream);
  18. >
  19.  
  20. Whoops!!  I assume you didn't mean to include "write" when you're 
  21. refering to the ifstream.
  22.  
  23. >but if I declare this variable:
  24. >
  25. >ostrstream temp_str_stream(temp_string, 2000);  // note this is 
  26. oSTRstream
  27. >
  28. >then the ifstream object stops working (ie. all reads from it return 
  29. NULL)
  30. >
  31. >any ideas?  thanks.
  32. >
  33. >Paul.
  34. >
  35.  
  36. First, I'll assume that temp_string actually is at least 2000 bytes
  37. long.  Have you checked where in_stream.fail() or in_stream.bad() 
  38. get set -- that may indicate where something's gone wrong.  
  39.  
  40. If you're actually writing to your ostrstream, make sure nothing out
  41. of bounds, of course.
  42.  
  43. Also, I'm not sure what you mean by return NULL.  Since most ifstream/
  44. istream methods return either istream& or an int, you may be 
  45. misinterpreting the result.  Certainly, simply declaring an ostrstream 
  46. should not interfere with your ifstream if all is well.
  47.  
  48. Ken Kolda
  49.  
  50.